﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;

namespace VehicleOOBWeb
{
    public static class HtmlHelperExtensions
    {
        public static HtmlString Cart(int vehicle_id, bool isLogin, string returnUrl)
        {
            StringBuilder sb = new StringBuilder();
            if (isLogin == true)
            {
                sb.AppendLine("<script src=\"/Scripts/cart.js\"></script>");
                sb.AppendLine("<div class=\"button-container\">");
                sb.AppendLine("<span>");
                sb.AppendLine("<input type=\"submit\" value=\"Mua ngay\" onclick=\"vehicle_cart.buyNow('" + vehicle_id + "')\"  />");
                sb.AppendLine("</span>");
                sb.AppendLine("<span>");
                sb.AppendLine("<input type=\"submit\" value=\"Đặt hàng\" onclick=\"vehicle_cart.addToCart('" + vehicle_id + "')\"  />");
                sb.AppendLine("</span>");
                sb.AppendLine("</div>");
            }
            else
            {
                sb.AppendLine("<div class=\"button-container\">");
                sb.AppendLine("<span>");
                sb.AppendLine("<input type=\"submit\" value=\"Mua ngay\" onclick=\"location.href='/Account/Login/?returnUrl=" + returnUrl + "'\"  />");
                sb.AppendLine("</span>");
                sb.AppendLine("<span>");
                sb.AppendLine("<input type=\"submit\" value=\"Đặt hàng\" onclick=\"location.href='/Account/Login/?returnUrl=" + returnUrl + "'\"  />");
                sb.AppendLine("</span>");
                sb.AppendLine("</div>");
            }
            return new HtmlString(sb.ToString());
        }       
    }
}